package com.example.mobile2030606148tdh0117hw;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private Button btnMainadd;
    private TextView tvMainName;
    private RecyclerView rvMainxinxi;
    private List<Users> list = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        list=new MyDataAdapter().QueryALL(this);
       rvMainxinxi.setAdapter(new UsersRViewAdapter(list));
       btnMainadd.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Intent intent = new Intent(MainActivity.this, MainActivity2.class);
               startActivity(intent);
           }
       });
    }

    private void initView() {
        textView = (TextView) findViewById(R.id.textView);
        btnMainadd = (Button) findViewById(R.id.btnMainadd);
        tvMainName = (TextView) findViewById(R.id.tvMainName);
        rvMainxinxi = (RecyclerView) findViewById(R.id.rvMainxinxi);
        rvMainxinxi.setLayoutManager(new LinearLayoutManager(this));
    }
}